import 'package:flutter/material.dart';
import 'package:flutter_bilibili/core/extension/int_extension.dart';
import 'package:flutter_bilibili/ui/shared/app_theme.dart';
import 'package:flutter_bilibili/ui/widgets/icon_route.dart';

class HYIconButtonRow extends StatelessWidget {
  Color iconColor;
  double size;
  List<IconRoute> iconList;

  HYIconButtonRow(
      {required this.iconColor, required this.size, required this.iconList});

  @override
  Widget build(BuildContext context) {
    List<Widget> widgets = [];
    for (IconRoute icon in iconList) {
      widgets.add(buildIconButton(
          context, icon.assetsRoute, icon.text, icon.realRoute));
    }
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceAround,
      children: widgets,
    );
  }

  Widget buildIconButton(
      BuildContext context, String icon, String text, String realRoute) {
    return GestureDetector(
      onTap: () {
        Navigator.of(context).pushNamed(realRoute);
      },
      child: Container(
        width: 80.px,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            SizedBox(
              child: icon.isEmpty
                  ? Center()
                  : Image.asset(
                      icon,
                      color: iconColor,
                    ),
              width: size,
              height: size,
            ),
            SizedBox(
              height: 10.px,
            ),
            Text(
              text,
              style: TextStyle(
                  fontSize: HYAppTheme.xxSmallFontSize,
                  color: Color.fromRGBO(70, 70, 70, 1)),
            )
          ],
        ),
      ),
    );
  }
}
